package com.kpmg.datalake.autopackage.enums;

/**
 * @Author: Richard.ji [richard.ji@kpmg.com]
 * @Date: 2018-08-21 09:32:28
 * @Description:
 */
public enum TemplateStatusEnum {

    /**
     * 正在上传
     */
    UPLOAD_UNFINISHED("1", "正在上传"),

    /**
     * 上传成功
     */
    UPLOAD_FINISHED("2", "上传成功"),

    /**
     * 上传失败
     */
    UPLOAD_ERROR("3", "上传失败");


    private String code;
    private String display;

    TemplateStatusEnum(String code, String display) {
        this.code = code;
        this.display = display;
    }

    public static String getNameByCode(String code) {
        if(code == null){
            return "";
        }

        for (TemplateStatusEnum c : TemplateStatusEnum.values()) {
            if (c.getCode().equals(code)) {
                return c.getDisplay();
            }
        }
        return null;
    }

    public static String getCodeByName(String display) {
        if(display == null){
            return "";
        }

        for (TemplateStatusEnum c : TemplateStatusEnum.values()) {
            if (display.equals(c.getDisplay())) {
                return c.getCode();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDisplay() {
        return display;
    }
}
